<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>业主投诉</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/dist.css">
</head>
<body>
<h1>业主投诉</h1>
<div class="layui-form-item">

    <div class="layui-inline" id="control">
        <div class="layui-btn-group">
            <button class="layui-btn" onclick="addRow(table)">增加</button>
            <button class="layui-btn" onclick="changeRows(chosedRows)">编辑</button>
            <button class="layui-btn layui-btn-danger" onclick="delRows(chosedRows)">删除</button>
        </div>
        <button class="layui-btn layui-btn-normal" onclick="confirm(submit_args)">确认更改</button>
    </div>
</div>
<table class="layui-table">
    <thead>
    <tr id="table_head">
        <td class="layui-form" id="choseAll">
            <input type="checkbox" lay-skin="primary">
        </td>
        <td>投诉编号</td>
        <td>投诉日期</td>
        <td>投诉用户</td>
        <td>接待人员</td>
        <td>物业地址</td>
        <td>电话</td>
        <td>投诉内容</td>
        <td>处理人员</td>
        <td>处理日期</td>
        <td>处理情况</td>
    </tr>
    </thead>
    <tbody id="show">
    </tbody>
</table>
<button onclick="getNext(-5,table)">上一页</button>
<button onclick="getNext(5,table)">下一页</button>
</body>
<script src="/layui/layui.js"></script>
<script src="/js/init.js"></script>
<script src="/js/fetch.js"></script>
<script src="/js/checkTable.js"></script>
<script src="/js/admin/submit.js"></script>
<script src="/js/admin/addRow.js"></script>
<script>

    let identity = 'user';
    document.getElementById('control').style.display = 'none';
    document.getElementById('choseAll').style.display = 'none';

    checkLogin('业主投诉管理').then(e => {
        order = checkTable(table, head);
        if (e.admin) {
            identity = 'admin';
            document.getElementById('control').style.display = 'block';
            document.getElementById('choseAll').style.display = 'block';
            init(identity);
        }else if (e.see) {
            order.shift();
            init(identity);
        }else document.write('<h1>对不起，你没有相关权限！</h1>');
        getNext(0, table);
    });

    let page_no = 0;
    let table = document.getElementById('show');
    let head = document.getElementById('table_head');
    let order;
    let submit_args = [];
    let admin_table = [];

    function init() {

        if (identity !== 'admin') {

        } else {
            admin_table.push({
                    type: 'checkbox',
                    content: 'chose',
                    isNode: true
                }, {
                    tip: '自动生成，推荐不填',
                    content: order[1],
                    beSubmit: 'complainNum',
                    isPrimary: true//删除的唯一标识字段
                },


                {
                    type: 'date',
                    content: order[2],
                    required: true,
                    beSubmit: 'complainDate'
                },


                {
                    tip: '长度最长20位',
                    content: order[3],
                    required: true,
                    beSubmit: 'ownerName'
                },


                {
                    tip: '长度最长20位',
                    content: order[4],
                    required: true,
                    beSubmit: 'serverName'
                },


                {
                    tip: '长度最长20位',
                    content: order[5],
                    required: true,
                    beSubmit: 'serverAddress'
                },


                {
                    required: true,
                    content: order[6],
                    beSubmit: 'complainTel'
                },


                {

                    content: order[7],
                    beSubmit: 'complainReason'
                },


                {
                    content: order[8],
                    beSubmit: 'solvePeople'
                },


                {
                    type: 'date',
                    content: order[9],
                    beSubmit: 'solveDate'
                },


                {
                    content: order[10],
                    beSubmit: 'result'
                }
            );
        }
    }


    let chosedRows = [];
</script>
</html>